package com.springcloud.kafka;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @author @1998
 * @date 2021-10-26 1823
 * @description null
 */
public class KafkaProducer{
    public static void main(String[] args) {

        List<Person> list = new ArrayList<>();
        list.add(new Person("zhangs",123));
        list.add(new Person("lisi",111));
        list.add(new Person("wangw",102));
        list.add(new Person("zhaol",120));
//        Collections.sort(list, Person::compareTo);
//
//        for (int i = 0; i < list.size(); i++) {
//            System.err.println(list.get(i));
//        }
        List<Person> collect = list.stream().sorted(Person::compareTo).collect(Collectors.toList());
        collect.stream().forEach(System.err::println);
    }



}
class Person implements Comparable<Person> {
    private String name;
    private Integer age;

    public Person(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public int compareTo(Person o) {
        return this.age.compareTo(o.age);
    }
    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
